<?php
/**
 * Created by PhpStorm.
 * User: yanghu
 * Date: 27/10/2017
 * Time: 3:02 PM
 */

class XingeHelperValidator
{
    public static function XingeAndroOne()
    {
        $only = ['name','author_intro','author_position'];

        $rules = [
            'name' => 'required',
            'author_intro' => 'required',
            'author_position' => 'required',
        ];

        $messages = [
            'name.required' => '讲师名称不能为空',
            'author_intro.required' => '讲师简介不能为空',
            'author_position.required' => '讲师职位不能为空',
        ];

        $input = $request->only($only);

        $validator = Validator::make($input, $rules, $messages);

        if ($validator->fails())
            exit(json_encode(['info'=>$validator->errors()->first(), 'code' => 1002]));

        return $input;

    }
}